Canadian Honeybee Production
Graphs of honeybee production in Canada using STATCAN data
Data
https://www150.statcan.gc.ca/t1/tbl1/en/cv.action?pid=3210035301
# devtools::install_github("derekmichaelwright/agData")
library(agData)
library(gganimate)Prepare Data
## Prep data
myCaption <- "www.dblogr.com/ or derekmichaelwright.github.io/dblogr/ | Data: STATCAN"
#
dd <- agData_STATCAN_Beehives %>%
mutate(Era = ifelse(Year >= 1994, "Post", "Pre"),
Era = factor(Era, levels = c("Pre", "Post")))All Honeybee Data
# Prep data
xx <- dd %>% filter(Area == "Canada", Measurement != "Value of honey and wax")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value)) +
geom_line(size = 1.25, color = "darkgreen", alpha = 0.7) +
facet_grid(Measurement + Unit ~ ., scales = "free", switch = "y",
labeller = label_wrap_gen(width = 14, multi_line = TRUE)) +
scale_x_continuous(breaks = seq(1925, 2020, 10), minor_breaks = NULL) +
coord_cartesian(xlim = c(min(xx$Year)+4, max(xx$Year)-4)) +
theme_agData(strip.placement = "outside", legend.position = "bottom") +
labs(title = "Canada - Honeybee", y = NULL, x = NULL, caption = myCaption)
ggsave("honeybee_canada_01.png", mp, width = 6, height = 8)Colonies
# Prep data
xx <- dd %>% filter(Measurement == "Colonies")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value)) +
geom_line(size = 1.5, color = "darkgreen", alpha = 0.7) +
scale_x_continuous(breaks = seq(1925, 2020, 10), minor_breaks = NULL) +
coord_cartesian(xlim = c(min(xx$Year)+4, max(xx$Year)-4)) +
theme_agData(strip.placement = "outside", legend.position = "none") +
labs(title = "Canada - Honeybee", x = NULL,
y = "Thousand Colonies", caption = myCaption)
ggsave("honeybee_canada_02.png", mp, width = 6, height = 4)# Prep data
xx <- dd %>% filter(Measurement == "Colonies")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value)) +
geom_line(aes(color = Era), size = 1.5, alpha = 0.7) +
scale_colour_manual(values = c("darkgoldenrod2", "darkgreen")) +
scale_x_continuous(breaks = seq(1925, 2020, 10), minor_breaks = NULL) +
coord_cartesian(xlim = c(min(xx$Year)+4, max(xx$Year)-4)) +
theme_agData(strip.placement = "outside", legend.position = "none") +
labs(title = "Canada - Honeybee", x = NULL,
y = "Thousand Colonies", caption = myCaption)
ggsave("honeybee_canada_03.png", mp, width = 6, height = 4)Animation
# Plot
mp <- mp + transition_reveal(Year)
anim_save("honeybee_canada_gif_01.gif", mp,
nframes = 300, fps = 20, end_pause = 60,
width = 900, height = 600, res = 150)Provinces
# Prep data
xx <- dd %>% filter(Measurement == "Colonies")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value, color = Area)) +
geom_line(size = 0.75, alpha = 0.7) +
facet_wrap(Area ~ ., scales= "free_y", ncol = 5) +
scale_color_manual(values = agData_Colors) +
scale_x_continuous(breaks = seq(1920, 2020, by = 20)) +
theme_agData(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Canada - Honeybee", x = NULL,
y = "Thousand Colonies", caption = myCaption)
ggsave("honeybee_canada_04.png", mp, width = 10, height = 4)Alberta vs. Ontario
# Prep data
xx <- dd %>% filter(Area %in% c("Alberta","Ontario"),
Measurement == "Colonies")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value, color = Area)) +
geom_line(size = 1.5, alpha = 0.7) +
scale_color_manual(name = NULL, values = c("darkblue", "darkred")) +
scale_x_continuous(breaks = seq(1920, 2020, by = 10)) +
theme_agData(legend.position = "bottom",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Canada - Honeybee", x = NULL,
y = "Thousand Colonies", caption = myCaption)
ggsave("honeybee_canada_05.png", mp, width = 6, height = 4)Saskatchewan vs. Quebec
# Prep data
xx <- dd %>% filter(Area %in% c("Saskatchewan", "Quebec"),
Measurement == "Colonies")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value, color = Area)) +
geom_line(size = 1.5, alpha = 0.7) +
scale_color_manual(name = NULL, values = c("steelblue", "darkgreen")) +
scale_x_continuous(breaks = seq(1920, 2020, by = 10)) +
theme_agData(legend.position = "bottom",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Canada - Honeybee", x = NULL,
y = "Thousand Colonies", caption = myCaption)
ggsave("honeybee_canada_06.png", mp, width = 6, height = 4)Saskatchewan
# Prep data
xx <- dd %>% filter(Area == "Saskatchewan", Measurement == "Colonies")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value, color = Area)) +
geom_line(size = 1.5, alpha = 0.7, color = "darkgreen") +
scale_x_continuous(breaks = seq(1920, 2020, by = 10)) +
theme_agData(legend.position = "bottom",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Saskatchewan - Honeybee", x = NULL,
y = "Thousand Colonies", caption = myCaption)
ggsave("honeybee_canada_07.png", mp, width = 6, height = 4)